package com.clqteam.serviceimpl;

import java.util.List;

import com.clqteam.dao.OrderInfoDao;
import com.clqteam.daoimpl.OrderInfoDaoImpl;
import com.clqteam.model.Product;
import com.clqteam.service.OrderInfoService;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;


public class OrderInfoServiceImpl implements OrderInfoService{

	OrderInfoDao oiDao = new OrderInfoDaoImpl();
	
	@Override
	public JSONObject findOrderInfoByOId(int oId,int page,int rows) {
		JSONObject j = new JSONObject();
		List<Product> pros = oiDao.getOrderInfoByOId(oId, page, rows);
		int total = oiDao.getOrderProductAmountByOId(oId);
		j.put("total", total);
		JSONArray js = new JSONArray();
		for(Product pro:pros){
			JSONObject pj = new JSONObject();
			pj.put("pAomount", pro.getpAmount());
			pj.put("pClass", pro.getpClass());
			pj.put("pCost", pro.getpCost());
			pj.put("pId", pro.getpId());
			pj.put("pName", pro.getpName());
			pj.put("poAmount", pro.getPoAmount());
			pj.put("pPrice", pro.getpPrice());
			pj.put("pTime", pro.getpTime());
			pj.put("pType", pro.getpType());
			pj.put("supId", pro.getSupId());
			pj.put("supName", pro.getSupName());
			js.add(pj);
		}
		j.put("rows", js);		
		return j;
	}

	@Override
	public JSONObject findTempOder() {
		// TODO Auto-generated method stub
		return null;
	}

}
